package com.zsrt.day20170427.am;

import java.lang.reflect.Field;
import java.security.InvalidKeyException;

import org.junit.Test;

/**
*@author jzh
*@创建时间 2017年4月27日下午12:16:12
*类说明：
*/
public class FieldTest {
	
	@Test
	public void FieldTest() throws Exception{
		Class clazz = Class.forName("com.zsrt.day20170427.am.Student");
		Object student = clazz.newInstance();
		Field[] fields = clazz.getFields();
		Field[] fields2 = clazz.getDeclaredFields();
		Field field2 = clazz.getField("name");
		//System.out.println(field2.getName());
		Field age = clazz.getDeclaredField("age");
		age.setAccessible(true);
		//System.out.println(age.get(student));
		
		System.out.println("fields"+fields.length);
		System.out.println(fields2.length);
		/*for(Field field:fields){
			System.out.println(field.getName());
			System.out.println(field.getType());
			System.out.println(field.getModifiers());
			System.out.println(field.get(student));
		}*/
		
		/*for(int i=0;i<fields2.length;i++){
			Field field=fields2[1];
			System.out.println(field.getName());
			System.out.println(field.getType());
			System.out.println(field.getModifiers());
			field.setAccessible(true);
			System.out.println(field.get(student));
		}*/
			
		
		
	}

}
